﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Threading;

namespace WOWMultiPlay
{
    public static class Helper_Timer
    {
        public static void Sleep(Helper_Profile.Profile.Button.TimeInterval TimeInterval)
        {
            Sleep_Millisecond(TimeInterval.Millisecond);
            Sleep_Second(TimeInterval.Second);
            Sleep_Minute(TimeInterval.Minute);
            Sleep_Hour(TimeInterval.Hour);
        }

        private static void Sleep_Millisecond(int period)
        {
            DateTime EndTime = DateTime.Now.AddMilliseconds(period);

            while (DateTime.Now < EndTime)
            {
                Thread.Sleep(1);
            }
        }

        private static void Sleep_Second(int period)
        {
            DateTime EndTime = DateTime.Now.AddSeconds(period);

            while (DateTime.Now < EndTime)
            {
                Thread.Sleep(50);
            }
        }

        private static void Sleep_Minute(int period)
        {
            DateTime EndTime = DateTime.Now.AddMinutes(period);

            while (DateTime.Now < EndTime)
            {
                Thread.Sleep(500);
            }
        }

        private static void Sleep_Hour(int period)
        {
            DateTime EndTime = DateTime.Now.AddMinutes(period);

            while (DateTime.Now < EndTime)
            {
                Thread.Sleep(5000);
            }
        }
    }
}
